//建立父控制器
//基本控制层
app.controller('baseController',function ($scope) {

    //定义分页配置
    $scope.paginationConf = {
        currentPage: 1,   //当前页码
        totalItems: 10, //总记录数
        itemsPerPage: 10,//每页显示记录数
        perPageOptions: [10, 15, 20, 30, 40, 50],//选择每页显示记录数下拉菜单选项
        onChange: function () {
            //从后台刷新读取分页数据
            $scope.reloadList();
        }
    }
    //重新加载列表 数据
    $scope.reloadList = function () {
        //切换页码
        $scope.search($scope.paginationConf.currentPage, $scope.paginationConf.itemsPerPage);

    }


    $scope.selectIds=[];
    //更新复选
    $scope.updateSelection=function ($event,id) {
        //如果是被选中，则增加到数组
        if ($event.target.checked){
            $scope.selectIds.push(id);
        }else {
            var  idx=$scope.selectIds.indexOf(id);
            //删除
            $scope.selectIds.splice(idx,1);

        }

    }
    $scope.checkedAll = function ($event) {
        if ($event.target.checked) {
            angular.forEach($scope.list, function (brand) {
                $scope.ids.push(brand.id);
            })
        } else {
            $scope.ids = [];
        }
    }

})